<table width="100%"><tr><td width="20%">
<a href="../index.html">&lt; index</a><br />
<a href="index.html">&lt; 10. Noise generator</a><br />
</td><td width="60%">
<p align="center">
=====================================<br />
10.1 Creating a noise generator<br />
=====================================<br />
</p></td><td width="20%">
<a href="noise_perlin.html">&gt; 10.2 Getting Perlin noise</a>
</td></tr></table>
<style type="text/css">
.code { color:#444444; background-color:#EEEEEE;}
pre { color:#444444; background-color:#EEEEEE;}
table.param td { border : 1px solid #000000; }
th { background-color: #44BBFF; color: #FFFFFF }
table.none td { border : 0 }
</style>
Those functions initialize a noise generator from a number of dimensions (from 1 to 4), some fractal parameters and a random number generator.<br />
<p class="code"><pre>
C   : TCOD_noise_t TCOD_noise_new(int dimensions, float hurst, float lacunarity, TCOD_random_t random)
Py  : noise_new(dimensions, hurst=NOISE_DEFAULT_HURST, lacunarity=NOISE_DEFAULT_LACUNARITY, random=0)
</pre></p>
<br />
<table class="param">
<tr><th>Parameter</th><th>Description</th></tr>
<tr><td>dimensions</td><td>From 1 to 4.<br /></td></tr>
<tr><td>hurst</td><td>For fractional brownian motion and turbulence, the fractal <a href="http://en.wikipedia.org/wiki/Hurst_exponent">Hurst exponent</a>. You can use the default value TCOD_NOISE_DEFAULT_HURST = 0.5f.<br /></td></tr>
<tr><td>lacunarity</td><td>For fractional brownian motion and turbulence, the fractal lacunarity. You can use the default value TCOD_NOISE_DEFAULT_LACUNARITY = 2.0f.<br /></td></tr>
<tr><td>random</td><td>A random number generator obtained with the <a href="../random/index.html">Mersenne twister toolkit</a> or NULL to use the default random number generator.<br /></td></tr>
</table>
<br />
The C++ version provides several constructors. When the hurst and lacunarity parameters are omitted, default values (TCOD_NOISE_DEFAULT_HURST = 0.5f and TCOD_NOISE_DEFAULT_LACUNARITY = 2.0f) are used.<br />
<p class="code"><pre>
C++ : TCODNoise::TCODNoise(int dimensions)
      TCODNoise::TCODNoise(int dimensions, TCODRandom *random)
      TCODNoise::TCODNoise(int dimensions, float hurst, float lacunarity)
      TCODNoise::TCODNoise(int dimensions, float hurst, float lacunarity, TCODRandom *random)
</pre></p>
<br />
Example :<br />
<p class="code"><pre>
C++ : // 1 dimension generator
      TCODNoise * noise1d = new TCODNoise(1);
      // 2D noise with a predefined random number generator
      TCODRandom *myRandom = new TCODRandom();
      TCODNoise *noise2d = new TCODNoise(2,myRandom);
      // a 3D noise generator with a specific fractal parameters
      TCODNoise *noise3d = new TCODNoise(3,0.7f,1.4f);
C   : /* 1 dimension generator */
      TCOD_noise_t noise1d = TCOD_noise_new(1,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
      /* 2D noise with a predefined random number generator */
      TCOD_random_t my_random = TCOD_random_new();
      TCOD_noise_t noise2d = TCOD_noise_new(2,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,my_random);
      /* a 3D noise generator with a specific fractal parameters */
      TCOD_noise_t noise3d = TCOD_noise_new(3,0.7f, 1.4f,NULL);
Py  : # 1 dimension generator 
      noise1d = libtcod.noise_new(1)
      # 2D noise with a predefined random number generator 
      my_random = libtcod.random_new();
      noise2d = libtcod.noise_new(2,libtcod.NOISE_DEFAULT_HURST, libtcod.NOISE_DEFAULT_LACUNARITY,my_random)
      # a 3D noise generator with a specific fractal parameters 
      noise3d = libtcod.noise_new(3, 0.7, 1.4)
</pre></p>
